# 导入flask
from flask import Flask
from flask import request,jsonify
#导入时间模块
import time



# 建立flask实例
app = Flask(__name__)

# 全局配置跨域
from flask_cors import CORS
cors = CORS(app)



#导入配置文件
from comm import  Config

# 导入用户模块
from user_view import user

# 解决中文乱码
app.config['JSON_AS_ASCII']=False


# 注册蓝图
app.register_blueprint(user,url_prefix='/user')



# 试图
#不加methods 默认GET请求方式  支持8种   不写默认支持1中GET
# @app.route('/',methods=['GET','POST','PUT','DELETE'])
# async def hello_word():
#
#     #通过url传参
#     # data = request.args.get('id')
#     # print(data)
#     #post 通过form表单传参
#     data = request.form.get('id')
#     print(data)
#
#     return {"code":200,'msg':'你好世界'}
#
# # 耗时任务
# async def get_data():
#     time.sleep(5)
#
# # 性能接口
# @app.route('/data/')
# async def mydata():
#     print('开始执行')
#     time.sleep(5)
#     await get_data()
#     print("执行结束")
#
#     return{"msg":'执行结束'}

# 调用实例对象
if __name__ == '__main__':
    app.run(debug=True,host='0.0.0.0',port=5000)


